from django.db import models

# 每个基地的容器命名和数量不同，所以建立容器和基地对应表
class Tank(models.Model):
    base = models.CharField(max_length=32)
    system = models.CharField(max_length=32)
    name = models.CharField(max_length=32)

    def __str__(self):
        return self.base + "-" + self.name

# 信号类型表
class Signal(models.Model):
    name = models.CharField(max_length=32)

    def __str__(self):
        return self.name

# 涡流数据模型
class Etdata(models.Model):
    outage = models.CharField(max_length=32)
    tank = models.CharField(max_length=64)
    add_time = models.DateTimeField(auto_now_add=True)
    edit_time = models.DateTimeField(auto_now=True)
    zone = models.CharField(max_length=16)
    row = models.IntegerField()
    col = models.IntegerField()
    cal = models.CharField(max_length=32)
    ext = models.CharField(max_length=16)
    leg = models.CharField(max_length=16)
    code = models.CharField(max_length=16)
    volt = models.FloatField(blank=True, null=True)
    ph = models.IntegerField(blank=True, null=True)
    ch = models.CharField(max_length=16, blank=True, null=True)
    percent = models.IntegerField(blank=True, null=True)
    sup = models.CharField(max_length=32, blank=True, null=True)
    dist = models.IntegerField(blank=True, null=True)
    sup2 = models.CharField(max_length=32, blank=True, null=True)
    dist2 = models.IntegerField(blank=True, null=True)
    long = models.CharField(max_length=16, blank=True, null=True)
    probe = models.CharField(max_length=32, blank=True, null=True)
    arc = models.CharField(max_length=32, blank=True, null=True)
    noise = models.CharField(max_length=32, blank=True, null=True)
    analyst = models.CharField(max_length=32, blank=True, null=True)
    date = models.DateTimeField(blank=True, null=True)
    analysis = models.CharField(max_length=32, blank=True, null=True)
    priority = models.IntegerField(blank=True, null=True)
    def __str__(self):
        return self.outage + self.tank + 'R' + str(self.row) + 'C' + str(self.col) + self.code




